//
//  JQFYTabbarController.m
//  JQFY
//
//  Created by apple on 2017/8/6.
//  Copyright © 2017年 yannis. All rights reserved.
//

#import "JQFYTabbarController.h"
#import "JQFYTabView.h"
#import "JQFYBaseNavigationController.h"
#import "JQFYLonginViewController.h"
#import "JQFYHomeViewController.h"
#import "JQFYTicketPageViewController.h"
#import "JQFYMineViewController.h"
#import "JQFYMineBaseNavController.h"
#import "JQFYActivityViewController.h"

@interface JQFYTabbarController ()<JQFYBottomBarViewDelegate>
@property (nonatomic ,strong)NSArray* controllerArray;
@end
@implementation JQFYTabbarController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setupUI];
}

-(void)setupUI{
    [self setViewControllers:self.controllerArray];
    JQFYTabView *view = [[JQFYTabView alloc]initWithFrame:self.tabBar.bounds];
    [self.tabBar addSubview:view];
    self.selectedIndex = 0;
    view.delegate = self;
    //监听通知
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didClickStart) name:@"didClickStartButton" object:nil];
}

-(void)didClickStart{
    self.selectedIndex = 0;
}

-(void)bottomBarView:(JQFYTabView *)bottomBarView didClickBottomBarButton:(int)idx{
        self.selectedIndex = idx - 1;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

-(NSArray *)controllerArray{
    if (_controllerArray == nil) {
        JQFYHomeViewController *homeVc = [[JQFYHomeViewController alloc]init];
        JQFYActivityViewController *activityVc = [[JQFYActivityViewController alloc]init];
//        JQFYTicketPageViewController *ticketVc = [[JQFYTicketPageViewController alloc]init];
        JQFYMineViewController *mineVc = [[JQFYMineViewController alloc]init];
        NSArray* array = @[[[JQFYMineBaseNavController alloc]initWithRootViewController:homeVc],
//                           [[JQFYBaseNavigationController alloc]initWithRootViewController:playerVc],
                           [[JQFYBaseNavigationController alloc]initWithRootViewController:activityVc],
                           [[JQFYMineBaseNavController alloc]initWithRootViewController:mineVc]];
        _controllerArray = array;
    }
    return _controllerArray;
}


@end
